//
//  Utils.swift
//  MyOfO
//
//  Created by Yuri on 2018/3/29.
//  Copyright © 2018年 Yuri. All rights reserved.
//

import Foundation
import AVFoundation

class Utils {
    
    //后置闪光灯开关
    static func turnTorch() {
        print("turnTorch")
        guard let device = AVCaptureDevice.default(for: .video) else { return }
        
        if device.hasTorch && device.isTorchAvailable {
            try? device.lockForConfiguration()
            
            if device.torchMode == .off {
                device.torchMode = .on
            } else {
                device.torchMode = .off
            }
            
            device.unlockForConfiguration()
        }
        
    }
    
}

